package com.doge.walknovel.deeplink

import android.net.Uri
import com.doge.walknovel.business.novel.NovelDetailActivity
import com.doge.walknovel.business.novel.NovelRefer
import com.doge.walknovel.push.PushHelper
import com.doge.walknovel.utils.Activities
import com.doge.walknovel.utils.appContext
import com.doge.walknovel.utils.log

object DeepLinkHelper {
    fun handleIntent(data: Uri?, flag: Int): Boolean {
        if (data == null) return false
        log("DeepLinkHelper handleIntent $data")
        return when (data.getQueryParameter("type")) {
            PushHelper.TYPE_NOVEL_DETAIL -> {
                NovelDetailActivity.start(
                    Activities.top ?: appContext,
                    data.getQueryParameter("novelId")?.toIntOrNull(),
                    NovelRefer.deepLink, flag
                )
                true
            }
            else -> false
        }
    }
}